#
#	Makefile for dcmpstat/apps
#


@SET_MAKE@

SHELL = /bin/sh
VPATH = @srcdir@:@top_srcdir@/include:@top_srcdir@/@configdir@/include
srcdir = @srcdir@
top_srcdir = @top_srcdir@
configdir = @top_srcdir@/@configdir@

include $(configdir)/@common_makefile@

ofstddir = $(top_srcdir)/../ofstd
ofstdinc = -I$(ofstddir)/include
ofstdlibdir = -L$(ofstddir)/libsrc
ofstdlib = -lofstd

dcmdatadir = $(top_srcdir)/../dcmdata
dcmdatainc = -I$(dcmdatadir)/include
dcmdatalibdir = -L$(dcmdatadir)/libsrc
dcmdatalib = -ldcmdata

dcmnetdir = $(top_srcdir)/../dcmnet
dcmnetinc = -I$(dcmnetdir)/include
dcmnetlibdir = -L$(dcmnetdir)/libsrc
dcmnetlib = -ldcmnet

dcmimgledir = $(top_srcdir)/../dcmimgle
dcmimgleinc = -I$(dcmimgledir)/include
dcmimglelibdir = -L$(dcmimgledir)/libsrc
dcmimglelib = -ldcmimgle

dcmpstatdir = $(top_srcdir)/../dcmpstat
dcmpstatinc = -I$(dcmpstatdir)/include
dcmpstatlibdir = -L$(dcmpstatdir)/libsrc
dcmpstatlib = -ldcmpstat

dcmqrdbdir = $(top_srcdir)/../dcmqrdb
dcmqrdbinc = -I$(dcmqrdbdir)/include
dcmqrdblibdir = -L$(dcmqrdbdir)/libsrc
dcmqrdblib = -ldcmqrdb

dcmtlsdir = $(top_srcdir)/../dcmtls
dcmtlsinc = -I$(dcmtlsdir)/include
dcmtlslibdir = -L$(dcmtlsdir)/libsrc
dcmtlslib = -ldcmtls

dcmsigndir = $(top_srcdir)/../dcmsign
dcmsigninc = -I$(dcmsigndir)/include
dcmsignlibdir = -L$(dcmsigndir)/libsrc
dcmsignlib = -ldcmdsig

dcmsrdir = $(top_srcdir)/../dcmsr
dcmsrinc = -I$(dcmsrdir)/include
dcmsrlibdir = -L$(dcmsrdir)/libsrc
dcmsrlib = -ldcmsr

LOCALINCLUDES = $(dcmpstatinc) $(ofstdinc) $(dcmnetinc) $(dcmdatainc) $(dcmimgleinc) \
	$(dcmqrdbinc) $(dcmtlsinc) $(dcmsigninc) $(dcmsrinc)
LIBDIRS = -L$(top_srcdir)/libsrc $(dcmpstatlibdir) $(dcmqrdblibdir) $(dcmnetlibdir) \
	$(dcmtlslibdir) $(dcmsignlibdir) $(dcmsrlibdir) $(dcmdatalibdir) $(ofstdlibdir) \
	$(dcmimglelibdir)
LOCALLIBS = $(dcmpstatlib) $(dcmsignlib) $(dcmimglelib) $(dcmsrlib) $(dcmqrdblib) $(dcmnetlib) \
	$(dcmtlslib) $(dcmdatalib) $(ofstdlib) $(XMLLIBS) $(ZLIBLIBS) $(TCPWRAPPERLIBS) $(OPENSSLLIBS)
DCMMKLUT_LIBS = $(dcmimglelib) $(dcmdatalib) $(ofstdlib) $(XMLLIBS) $(ZLIBLIBS) 
DCMMKCRV_LIBS = $(dcmdatalib) $(ofstdlib) $(XMLLIBS) $(ZLIBLIBS)

objs = dcmpsmk.o dcmp2pgm.o dcmmklut.o dcmmkcrv.o dcmpssnd.o dcmpsrcv.o dcmpsprt.o dcmprscu.o \
	dcmprscp.o vrscan.o dcmpschk.o
progs = dcmpsmk dcmp2pgm dcmmklut dcmmkcrv dcmpssnd dcmpsrcv dcmpsprt dcmprscu dcmprscp dcmpschk


all: $(progs)

dcmpsmk: dcmpsmk.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmpsmk.o $(LOCALLIBS) $(MATHLIBS) $(LIBS)

dcmp2pgm: dcmp2pgm.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmp2pgm.o $(LOCALLIBS) $(MATHLIBS) $(LIBS)

dcmmklut: dcmmklut.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmmklut.o $(DCMMKLUT_LIBS) $(MATHLIBS) $(LIBS)

dcmmkcrv: dcmmkcrv.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmmkcrv.o $(DCMMKCRV_LIBS) $(MATHLIBS) $(LIBS)

dcmpssnd: dcmpssnd.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmpssnd.o $(LOCALLIBS) $(MATHLIBS) $(LIBS)

dcmpsrcv: dcmpsrcv.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmpsrcv.o $(LOCALLIBS) $(MATHLIBS) $(LIBS)

dcmpsprt: dcmpsprt.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmpsprt.o $(LOCALLIBS) $(MATHLIBS) $(LIBS)

dcmprscu: dcmprscu.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmprscu.o $(LOCALLIBS) $(MATHLIBS) $(LIBS)

dcmprscp: dcmprscp.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmprscp.o $(LOCALLIBS) $(MATHLIBS) $(LIBS)

dcmpschk: dcmpschk.o vrscan.o
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBDIRS) -o $@ dcmpschk.o vrscan.o $(LOCALLIBS) $(MATHLIBS) $(LIBS)


install: all
	$(configdir)/mkinstalldirs $(bindir)
	for prog in $(progs); do \
		$(INSTALL_PROGRAM) $$prog$(BINEXT) $(bindir); strip $(bindir)/$$prog$(BINEXT) ;\
	done

clean:
	rm -f $(objs) $(progs) $(TRASH)

distclean:
	rm -f $(objs) $(progs) $(DISTTRASH)


dependencies:
	$(CXX) -MM $(defines) $(includes) $(CPPFLAGS) $(CXXFLAGS) *.cc  > $(DEP)

include $(DEP)
